package com.ruoyi.project.carNext.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.carNext.domain.CarNextStatus;
import com.ruoyi.project.carNext.service.ICarNextStatusService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小车状态Controller
 * 
 * @author ruoyi
 * @date 2025-01-20
 */
@Controller
@RequestMapping("/system/status")
public class CarNextStatusController extends BaseController
{
    private String prefix = "system/status";

    @Autowired
    private ICarNextStatusService carNextStatusService;

    @GetMapping()
    public String status()
    {
        return prefix + "/status";
    }

    /**
     * 查询小车状态列表
     */
    @RequiresPermissions("system:status:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CarNextStatus carNextStatus)
    {
        startPage();
        List<CarNextStatus> list = carNextStatusService.selectCarNextStatusList(carNextStatus);
        return getDataTable(list);
    }

    @GetMapping("/area")
    public String selectCustomer() {
        return prefix + "/area";
    }

    /**
     * 导出小车状态列表
     */
    @RequiresPermissions("system:status:export")
    @Log(title = "小车状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CarNextStatus carNextStatus)
    {
        List<CarNextStatus> list = carNextStatusService.selectCarNextStatusList(carNextStatus);
        ExcelUtil<CarNextStatus> util = new ExcelUtil<CarNextStatus>(CarNextStatus.class);
        return util.exportExcel(list, "小车状态数据");
    }

    /**
     * 新增小车状态
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存小车状态
     */
    @RequiresPermissions("system:status:add")
    @Log(title = "小车状态", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CarNextStatus carNextStatus)
    {
        return toAjax(carNextStatusService.insertCarNextStatus(carNextStatus));
    }

    /**
     * 修改小车状态
     */
    @RequiresPermissions("system:status:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CarNextStatus carNextStatus = carNextStatusService.selectCarNextStatusById(id);
        mmap.put("carNextStatus", carNextStatus);
        return prefix + "/edit";
    }

    /**
     * 修改保存小车状态
     */
    @RequiresPermissions("system:status:edit")
    @Log(title = "小车状态", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CarNextStatus carNextStatus)
    {
        return toAjax(carNextStatusService.updateCarNextStatus(carNextStatus));
    }

    /**
     * 删除小车状态
     */
    @RequiresPermissions("system:status:remove")
    @Log(title = "小车状态", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(carNextStatusService.deleteCarNextStatusByIds(ids));
    }
}
